'use strict';

module.exports =collectSameElements; 
function collectSameElements(collectionA, collectionB) {
  let result =[];
  let a = (collectionB+'');
 
  let arr=a.split(',');
  let s1=arr.map(function(x){
    return x;
});


let m=collectionA.length;
let n=s1.length;
for(let i=0;i<m;i++){
  for(let j=0;j<n;j++){
    if(collectionA[i]===s1[j]){
      result.push(collectionA[i]);
    }
  }
}
console.log(result);
return result;
  
}
collectSameElements(['a', 'e', 'h', 't', 'f', 'c', 'g', 'b', 'd'],[['a', 'd', 'e', 'f']])